package com.liu.cloud.controller;

import com.liu.cloud.config.UserProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LIU
 * @version 1.0
 * @description: TODO
 * @date 2023/6/18 12:49
 *
 * @RefreshScope 支持动态刷新@Value注解
 */
@RestController
@RequestMapping("/order")
public class UserController {


    @Value("${user.username}")
    String username;
    @Value("${user.age}")
    String age;

    @RequestMapping()
    public String add(){
        return  String.format("hello world  user: %s ,age: %s",username,age);
    }


    /**
     * @ConfigurationProperties 默认支持动态刷新
     */
    @Autowired
    UserProperties userProperties;


    @RequestMapping("/properties")
    public String getUsername(){
        return  String.format("hello world  user: %s ,age: %s",userProperties.getUsername(), userProperties.getAge());
    }


}
